setwd("D:/Data/My Books/INDC - Pemrograman-Pengenalan Bahasa Pemrograman R/source/Pengenalan.Bahasa.Pemrograman.R")

data_pasien = read.table("Bab4DataPasien.txt", header = TRUE)
hist(data_pasien$AGE)
plot(density(data_pasien$AGE))

plot.multi.dens <- function(s)
{
  junk.x = NULL
  junk.y = NULL
  for(i in 1:length(s)) {
    junk.x = c(junk.x, density(s[[i]])$x)
    junk.y = c(junk.y, density(s[[i]])$y)
  }
  xr <- range(junk.x)
  yr <- range(junk.y)
  plot(density(s[[1]]), xlim = xr, ylim = yr, main = "")
  for(i in 1:length(s)) {
    lines(density(s[[i]]), xlim = xr, ylim = yr, col = i)
  }
}
